package com.nopay.dxdwphone.dialog;

import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import androidx.annotation.NonNull;
import com.nopay.dxdwphone.R;

public class DialogSubmitError extends Dialog {

    public DialogSubmitError(@NonNull Activity context) {
        super(context, R.style.MyDialog);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_submit_error);

        findViewById(R.id.tv_dialog_cancel).setOnClickListener(v -> {
            dismiss();
            if(onSubmitAgainListener != null) onSubmitAgainListener.onSubmitAgain(false);
        });
        findViewById(R.id.tv_dialog_confirm).setOnClickListener(v -> {
            dismiss();
            if(onSubmitAgainListener != null) onSubmitAgainListener.onSubmitAgain(true);
        });
    }

    private OnSubmitAgainListener onSubmitAgainListener;

    public DialogSubmitError setOnSubmitAgainListener(OnSubmitAgainListener onSubmitAgainListener) {
        this.onSubmitAgainListener = onSubmitAgainListener;
        return this;
    }

    public interface OnSubmitAgainListener {

        void onSubmitAgain(boolean isAgain);
    }
}
